#define _GLIBCXX_USE_CXX11_ABI 0

#include <iostream>
#include "YTFaceDetection.hpp"
#include "ytcommon.h"
//#include "TimeCounter.h"
using namespace std ;
using namespace yt_backend_facetrackpro;
int main(int argc, char*argv[])
{
//    int authInitRet = YTCommon::initAuth("/home/dmsoft/ClionProjects/liveness/licence_path/tool_license_generate_1.2");
//    cout << "auth ret : "<<authInitRet <<endl;
//
//    if(argc!=2){
//        cout<<"input image "<<endl;
//        return -1;
//    }
//    int initRet = YTFaceDetection::GlobalInit("/home/dmsoft/ClionProjects/liveness/model/");
//    cout << "initRet : "<< initRet <<endl;
//     if(initRet!=0){
//        cout<<"init failed "<<endl;
//         return initRet;
//     }

     string imgPath = "/home/dmsoft/桌面/yt-3dfaceliveness/v1.0.1/color_47709.jpg";
     cv::Mat  img_bgr = cv::imread(imgPath);
     if(img_bgr.empty()){
         cout<<"image is empty"<<endl;
         return -1;
     }

     cv::Mat  img_rgb;
     cv::cvtColor(img_bgr, img_rgb, cv::COLOR_BGR2RGB);

     YTFaceDetection* p_yt_fd = new YTFaceDetection();

     vector<cv::Rect> face_rects;
//     TimeCounter timer("detect");
//     timer.begin();
     p_yt_fd->Detection(img_rgb, face_rects);
//     timer.end(true);

     for(int k=0; k<face_rects.size(); ++k){
        cv::Rect  R = face_rects[k];
        cv::rectangle(img_bgr, R, cv::Scalar(0, 255, 0), 2);
     }
     cv::imwrite("data/detect/sdk_out.jpg", img_bgr);

     cout<<"face number:  "<<face_rects.size()<<endl;

     //delete obejct
     delete p_yt_fd;

     //Global exit
     YTFaceDetection::GlobalRelease();

     return 0;

}
